<?php
class Post extends AppModel {
	public $actsAs = array (
			'Containable' 
	);
	 public $hasMany = array (
			'Comment' => array (
					'className' => 'Comment',
	 	 			'order' => 'Comment.created DESC'
			) 
	);   
	
	public $belongsTo = array (
			'User' => array (
					'className' => 'User',
					'fields' => array ('User.id', 'User.username', 'User.fullname') 
			) 
	); 
	
	// tan
	public function findAllCreatedPost($userId) {
		return $this->find ( 'all', array (
				'conditions' => array (
						'Post.user_id' => $userId 
				),
				'fields' => 'created' 
		) );
	}
}